float4x4 World;
float4x4 View;
float4x4 Projection;
float4 Color;

// TODO: add effect parameters here.

struct VertexShaderInput
{
    float4 Position : POSITION0;
	float2 texCoord : TEXCOORD0;

    // TODO: add input channels such as texture
    // coordinates and vertex colors here.
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
	float2 texCoord : TEXCOORD0;

    // TODO: add vertex shader outputs such as colors and texture
    // coordinates here. These values will automatically be interpolated
    // over the triangle, and provided as input to your pixel shader.
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
	output.texCoord = input.texCoord;

    // TODO: add your vertex shader code here.

    return output;
}

float4 SquarePixelShaderFunction(VertexShaderOutput input) : COLOR0
{
	float dist = distance(input.texCoord, float2(.5, .5))*2;
    return float4(Color.rgb, (1 - mul(dist,dist)) * Color.w);
}

float4 LinearPixelShaderFunction(VertexShaderOutput input) : COLOR0
{
	float dist = distance(input.texCoord, float2(.5, .5))*2;
    return float4(Color.rgb, (1 - dist) * Color.w);
}

float4 SolidPixelShaderFunction(VertexShaderOutput input) : COLOR0
{
	float dist = distance(input.texCoord, float2(.5, .5))*2;
	if(dist>1)
		dist = 0;
	else
		dist = Color.w;

    return float4(Color.rgb, dist);
}

technique Linear
{
    pass Pass1
    {
        AlphaBlendEnable = TRUE;
        DestBlend = INVSRCALPHA;
        SrcBlend = SRCALPHA;
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 LinearPixelShaderFunction();
    }
}

technique Square
{
    pass Pass1
    {
        AlphaBlendEnable = TRUE;
        DestBlend = INVSRCALPHA;
        SrcBlend = SRCALPHA;
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 SquarePixelShaderFunction();
    }
}

technique Solid
{
    pass Pass1
    {
        AlphaBlendEnable = TRUE;
        DestBlend = INVSRCALPHA;
        SrcBlend = SRCALPHA;
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 SolidPixelShaderFunction();
    }
}
